
package com.zcp.pcsuitall.uitest;

import com.jayway.android.robotium.solo.Solo;
import com.zcp.pcsuitall.HotActivity;
import com.zcp.pcsuitall.PhoneServiceAllActivity;
import com.zcp.pcsuitall.SuitUtil;
import com.zcp.pcsuitall.WifiActivity;

import android.test.ActivityInstrumentationTestCase2;

public class PhoneServiceAllActivityTest extends
        ActivityInstrumentationTestCase2<PhoneServiceAllActivity> {

    private Solo solo;

    public PhoneServiceAllActivityTest() {
        super("com.zcp.pcsuitall", PhoneServiceAllActivity.class);
    }

    @Override
    public void setUp() throws Exception {
        solo = new Solo(getInstrumentation(), getActivity());
        solo.sleep(500);
    }

    @Override
    public void tearDown() throws Exception {
        try {
            // Robotium will finish all the activities that have been opened
            solo.finalize();
        } catch (Throwable e) {
            e.printStackTrace();
        }
        getActivity().finish();
        super.tearDown();
    }

    public void testWifi() throws Exception {
        solo.clickOnButton(0);
        solo.assertCurrentActivity("WifiActivity open error", WifiActivity.class);
    }

    public void testHot() throws Exception {
        solo.clickOnButton(1);
        solo.assertCurrentActivity("HotActivity open error", HotActivity.class);
    }

    public void testWifiClick() throws Exception {
        solo.clickOnButton(0);
        solo.assertCurrentActivity("WifiActivity open error", WifiActivity.class);
        solo.clickOnButton(0);
        if (SuitUtil.isWifiEnable(solo.getCurrentActivity())) {

            solo.assertCurrentActivity("PhoneServiceAllActivity open error",
                    PhoneServiceAllActivity.class);
        }
    }

    public void testHotClick() throws Exception {
        solo.clickOnButton(1);
        solo.assertCurrentActivity("HotActivity open error", HotActivity.class);
        solo.clickOnButton(0);
        if (SuitUtil.getWifiApEnable(solo.getCurrentActivity())) {

            solo.assertCurrentActivity("PhoneServiceAllActivity open error",
                    PhoneServiceAllActivity.class);
        }
    }
}
